//
//  ShopCartEditTableViewCell.m
//  EasyToTesco
//
//  Created by mc on 16/2/19.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "ShopCartEditTableViewCell.h"
<<<<<<< HEAD
#import "UIImageView+WebCache.h"
=======
>>>>>>> dd1aac4040986135177ad18eb7781566439f59ee

@implementation ShopCartEditTableViewCell

#pragma mark - 工厂方法：创建cell，给tableView重用
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *reuseIdentifier = @"ShopCartEditTableViewCell";
    ShopCartEditTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ShopCartEditTableViewCell" owner:nil options:nil] lastObject];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.shopcartseletbtn.layer.cornerRadius = CGRectGetHeight(cell.shopcartseletbtn.frame)/2;
        cell.shopcartseletbtn.layer.masksToBounds = YES;
        cell.reductionBtn.layer.borderWidth = 1;
        cell.addBtn.layer.borderWidth = 1;
        cell.shopcartnum.layer.borderWidth = 1;
        cell.shopcartother.layer.borderWidth = 1;
    }
    
    return cell;
}

//给cell赋值
- (void)addEditCellValue:(SCProductInfo *)productInfoModel{
    self.selectState = productInfoModel.selectState;
<<<<<<< HEAD
//    self.shopcartname.image = [UIImage imageNamed:@"dress.png"];
    [self.shopcartname sd_setImageWithURL:[NSURL URLWithString:productInfoModel.shopPicUrl]];
=======
    self.shopcartname.image = [UIImage imageNamed:productInfoModel.shopPicUrl];
>>>>>>> dd1aac4040986135177ad18eb7781566439f59ee
    self.shopcartnum.text = productInfoModel.shopcartCount;
    self.shopcartother.text = [NSString stringWithFormat:@"类型:%@ 颜色:%@", productInfoModel.shopCartType, productInfoModel.shopcartColor];
    if (productInfoModel.selectState){
        _selectState = YES;
        [self.shopcartseletbtn setBackgroundImage:[UIImage imageNamed:@"flight_butn_check_select"] forState:UIControlStateNormal];
    }else{
        _selectState = NO;
       [self.shopcartseletbtn setBackgroundImage:[UIImage imageNamed:@"flight_butn_check_unselect"] forState:UIControlStateNormal];
    }
    
}

- (IBAction)shopcartReductionBtn:(id)sender {
    //判断是否选中, 如果没选中的话就不走代理方法,只有选中才走代理方法
    if (_selectState == YES){
        //调用代理
        [self.delegate reductionBtnClick:self andbutton:sender];
    }
}

- (IBAction)shopcartaddbtn:(id)sender {
    //判断是否选中，选中才能点击
    
    if (_selectState == YES){
        //调用代理
        [self.delegate addBtnClick:self andbutton:sender];
    }
}
- (IBAction)shopcartdeletBtn:(id)sender {
    [self.delegate deleteBtnClick:self andbutton:sender];
}

- (IBAction)shopcartBtnclick:(id)sender {
    [self.delegate editbtnClick:self button:sender];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
@end
